package com.situ.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class TimerAspect {

    @Around("execution(* com.situ.service.impl.*.*(..))")
    public Object doAround(ProceedingJoinPoint joinPoint) throws Throwable {
        //记录起始时间
        long start = System.currentTimeMillis();
        //执行业务方法
        Object result = joinPoint.proceed();
        //记录结束时间
        long end = System.currentTimeMillis();
        System.out.println("当前业务耗费"+(end - start)+"ms");
        return result;
    }

}
